<?php

class taskModule extends Module {
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	*/
	function __construct() {
		$this->includePhp('task', 'task');
	}
	
	
	/*
	 * 调用插件资源
	*/
	public function call($user, $method, $param) {
		//检查用户
		$customerId = Session::$user['customerId'];
		Session::switchCustomer(0);
		$uid = Session::$user['uid'];
		$quanUserModel=M("quan_user");
		Session::switchCustomer($customerId);
		$fromUId=$param->fromUId;
		$fromGuid=$param->fromGuid;
		$allowMethod="index|getTaskList|getReward|getTaskList";
		if(strpos($allowMethod,$method)){ 
			if(!$uid){
				Output::instance()->resultCode(1,"无权限访问");
				return;
			}
			$user=$quanUserModel->where("uid=$uid")->select();
			if(!$user || count($user) < 1){
				Output::instance()->resultCode(1,"无权限访问");
				return;
			}
		}

		switch ($method) {
			case "index":
			    task::getIndex($param);
			    break;
			case "getTask":

				$tId = $param->tId;
				if (!isset($tId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
			    task::getTask($param);
			    break;
			case "getTaskList":
				$qId = $param->qId;
				if (!isset($qId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
			    task::getTaskList($param);
			    break;
			case "updateTaskStatus":
				task::updateTaskStatus($param);
			    break;
			case "getReward":
				task::getReward($param);
			    break;
			case "getRewardGift":
				task::getRewardGift($param);
			    break;
			case "gettaskListData":
				task::gettaskListData($param);
			    break;
		}
	}
}


$module = new taskModule();
Module::addModule($module);
?>